rm(list = ls())
library(pacman)
p_load(tidyverse, ggplot2, msm, sandwich, here, xtable)
set.seed(12345)
# open parameters template
modelInputsParams <- read_excel("../simulations/simulations_input.xlsx", sheet="main")
modelInputsParams <- read_excel("../simulations/simulations_input.xlsx", sheet="main")
install.packages("read_excel")
# open parameters template
modelInputsParams <- read_excel("../simulations/simulations_input.xlsx", sheet="main")
rm(list = ls())
library(pacman)
p_load(tidyverse, ggplot2, msm, sandwich, here, xtable)
modelInputsParams <- read_excel("../simulations/simulations_input.xlsx", sheet="main")
install.packages("read_excel")
rm(list = ls())
library(pacman)
p_load(tidyverse, ggplot2, msm, sandwich, here, xtable)
library(read_excel)
library(read_excel)
modelInputsParams <- read_excel("../simulations/simulations_input.xlsx", sheet="main")
rm(list = ls())
library(pacman)
p_load(tidyverse, ggplot2, msm, sandwich, here, xtable, readxl)
set.seed(12345)
modelInputsParams <- read_excel("../simulations/simulations_input.xlsx", sheet="main")
load(file = "../simulations/simulations_output_2.Rda")
load(file = "../simulations/simulations_input_params.rda")
# predict discirmination rate from observed X in inverted function
getX <- function(y, model) {
b <- coef(model)[1]
c <- coef(model)[2]
d <- coef(model)[3]
x <- -(sqrt(-4*b*d+ c^2 + 4*d*y) + c)/(2*d)
return(x)
}
group_count <- read.csv("../figure_5/figure_5_input.csv")
rm(list = ls())
library(pacman)
p_load(tidyverse, ggplot2, msm, sandwich, here, xtable, readxl)
set.seed(12345)
modelInputsParams <- read_excel("../simulations/simulations_input.xlsx", sheet="main")
load(file = "../simulations/simulations_output_2.Rda")
load(file = "../simulations/simulations_input_params.rda")
# predict discirmination rate from observed X in inverted function
getX <- function(y, model) {
b <- coef(model)[1]
c <- coef(model)[2]
d <- coef(model)[3]
x <- -(sqrt(-4*b*d+ c^2 + 4*d*y) + c)/(2*d)
return(x)
}
group_count <- read.csv("../figure_5/figure_5_input.csv")
n_femmaj <- group_count$group_N[18]
n_malmaj <- group_count$group_N[13]
task_influence <- read.csv("../figure_1/intermediate_data/combined_groupgenderminfl_ratio_ravg_forgraphing.csv")
global_influence <- read.csv("../figure_1/intermediate_data/combined_groupfemvotesminfl_avgpre_ratio_forgraphing.csv")
spokesperson <- read.csv("../figure_1/intermediate_data/combined_genderspokes_ratio_ravg_forgraphing.csv")
femMajValues  <- c(task_influence$v2[1], global_influence$v2[1], spokesperson$v2[1])
maleMajValues <- c(task_influence$v2[2], global_influence$v2[2], spokesperson$v2[2])
femMajDiscrim <- getX(femMajValues, femaleMajorityTrend)
maleMajDiscrim <- getX(maleMajValues, maleMajorityTrend)
pointsFrame <- as.data.frame(cbind(femMajDiscrim, femMajValues, maleMajDiscrim, maleMajValues))
tab <- matrix(c(" ", " ", " ", modelInputsParams$`Male-majority groups`[1],
modelInputsParams$`Female-majority groups`[1], "Data",
round(modelInputsParams$`Male-majority groups`[2], digits=2),
round(modelInputsParams$`Female-majority groups`[2], digits=2), "Data",
round(modelInputsParams$`Male-majority groups`[3], digits=2),
round(modelInputsParams$`Female-majority groups`[3], digits=2), "Model",
' ',' ', ' ',
round(pointsFrame$maleMajValues[1], digits=2),
round(pointsFrame$femMajValues[1],digits=2), 'Data',
round(pointsFrame$maleMajDiscrim[1],digits=2),
round(pointsFrame$femMajDiscrim[1],digits=2), 'Model',
round(pointsFrame$maleMajValues[2], digits=2),
round(pointsFrame$femMajValues[2],digits=2), 'Data',
round(pointsFrame$maleMajDiscrim[2],digits=2),
round(pointsFrame$femMajDiscrim[2],digits=2), 'Model',
round(pointsFrame$maleMajValues[3], digits=2),
round(pointsFrame$femMajValues[3],digits=2), 'Data',
round(pointsFrame$maleMajDiscrim[3],digits=2),
round(pointsFrame$femMajDiscrim[3],digits=2), 'Model'), ncol=3, byrow=TRUE)
colnames(tab) <- c('male_majority','female_majority','source')
rownames(tab) <- c('Panel A', modelInputsParams$Measure[1],
modelInputsParams$Measure[2], modelInputsParams$Measure[3],
'Panel B', 'Votes per woman, task influence',
'Implied discrimination penalty (in SD)',
'Votes per woman, global influence',
'Implied discrimination penalty (in SD)',
'Votes per woman, incentivized spokesperson election',
'Implied discrimination penalty (in SD)')
tab <- as.table(tab)
tab
write.table(tab, file = "table_a15.txt", sep = "|",
row.names = TRUE, col.names = TRUE)
rm(list=ls())
library(dplyr)
library(modelsummary)
library(RStata)
library(gt)
library(estimatr)
#load original data
##Set working directory
#setwd("C:/Users/ganth/Dropbox/StrengthInNumbersReplicationPackage/replicable/table_a4")
#########################################################################################
load(file = "table_a4_dataset_1.Rda")
